<template>
  <BasicDrawer v-bind="$attrs" @register="registerDrawer" title="学生列表" width="1000px" @ok="handleSubmit">
    <BasicTable @register="registerTable" >
        <!--操作栏-->
      <template #action="{ record }">
        <TableAction :actions="getTableAction(record)" />
      </template>
    </BasicTable>
  </BasicDrawer>
</template>
<script lang="ts" setup>
  import { ref, unref } from 'vue';
  import { toRaw } from '@vue/reactivity';
  import { BasicDrawer, useDrawerInner } from '/src/components/Drawer';
  import { BasicTable, useTable, TableAction } from '/src/components/Table';
  import { useDesign } from '/@/hooks/web/useDesign';
  import { useListPage } from '/@/hooks/system/useListPage';
  import { studentColumns, studentSearchFormSchema } from '../SchoolBusRoutes.data';
  import { selectStudentByRoutesId} from '../SchoolBusRoutes.api';
  import { ColEx } from '/@/components/Form/src/types';
  import { useMessage } from '/@/hooks/web/useMessage';
  const $message = useMessage();

  // const { prefixCls } = useDesign('row-invalid');
  const routesId= ref('');
  const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
    routesId.value =data.routesId;
    setDrawerProps({ confirmLoading: false, showFooter: showFooter.value });
    setProps({ searchInfo: { routesId: unref(routesId)} });
    reload();
  });
  const { tableContext,onExportXls,onImportXls } = useListPage({
      tableProps:{
           title: '',
           api: selectStudentByRoutesId,
           columns :studentColumns,
           canResize:false,
           rowKey:'id',
           showActionColumn:false,
           useSearchForm:true,
           formConfig: {
              labelWidth: 65,
              schemas: studentSearchFormSchema,
              autoSubmitOnEnter:true,
              showAdvancedButton:true,
              fieldMapToNumber: [
              ],
              fieldMapToTime: [
              ],
            },
           actionColumn: {
               width: 120,
               fixed:'right'
            },
      },
     
  })
  const [registerTable, {reload,getForm,setProps},{ rowSelection, selectedRowKeys }] = tableContext


  const showFooter = ref(true);

  //提交事件
  async function handleSubmit() {
    try {
      // //提交表单
      // await saveOrUpdateUser(values, isUpdateVal);
      //关闭弹窗
      // let selectIds = toRaw(rowSelection.selectedRowKeys)
      // if(selectId.length==0) return $message('请先选择人员')
      // console.log(channelId.value)

      // await addselectAcPersonGroup({
      //     channelId:isNotchannelId.value,
      //     personList: selectIds
      // })

      closeDrawer();
      //刷新列表
      // emit('success',{isUpdateVal ,values});
    } finally {
      setDrawerProps({ confirmLoading: false });
    }
  }

  /**
    * 成功回调
    */
  function handleSuccess() {
      (selectedRowKeys.value = []) && reload();
   }
 
</script>
<style scoped lang="less">
  @prefix-cls: ~'@{namespace}-row-invalid';

  :deep(.@{prefix-cls}) {
    background: #f4f4f4;
    color: #bababa;
  }
</style>
